feat: implement event dispatching for incoming WhatsApp messages#230
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe WhatsApp incoming message service now dispatches provider events before processing messages. An event dispatcher is invoked with the event type, inbox, payload, and timestamp extracted from webhook parameters, enabling event tracking throughout the messaging pipeline. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@CodeRabbit review @codex review |
|
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
app/services/whatsapp/incoming_message_whatsapp_cloud_service.rb (1)
18-20: Minor style inconsistency with key access.This method uses symbol keys (
:entry,:changes,:field) viadig, whileprocessed_params(line 23) uses string keys ('changes','value') withtry. Both work due towith_indifferent_access, but the mixed style could cause confusion. Consider aligning the key access style for consistency.♻️ Optional: Align with symbol keys
def whatsapp_cloud_event_type - params.dig(:entry, 0, :changes, 0, :field) || 'unknown' + params.dig(:entry, 0, :changes, 0, :field) || 'unknown' end def processed_params - `@processed_params` ||= params[:entry].try(:first).try(:[], 'changes').try(:first).try(:[], 'value') + `@processed_params` ||= params.dig(:entry, 0, :changes, 0, :value) end🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/services/whatsapp/incoming_message_whatsapp_cloud_service.rb` around lines 18 - 20, The method whatsapp_cloud_event_type mixes symbol-key access with processed_params' string-key style; make the key access consistent by updating processed_params (or other callers) to use symbol keys (e.g. use :entry, :changes, :value) throughout, or alternatively change whatsapp_cloud_event_type to use string keys to match processed_params—pick one consistent convention and update references in whatsapp_cloud_event_type and processed_params so both use the same key style (refer to methods whatsapp_cloud_event_type and processed_params).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@spec/services/whatsapp/incoming_message_whatsapp_cloud_service_spec.rb`:
- Line 111: Remove the unused test variable by deleting the let(:dispatcher) {
instance_double(EventDispatcher) } declaration; the spec already stubs
Rails.configuration.dispatcher directly at the later block, so keep that stub
and remove the dead `dispatcher` symbol to avoid an unused variable in the spec.
---
Nitpick comments:
In `@app/services/whatsapp/incoming_message_whatsapp_cloud_service.rb`:
- Around line 18-20: The method whatsapp_cloud_event_type mixes symbol-key
access with processed_params' string-key style; make the key access consistent
by updating processed_params (or other callers) to use symbol keys (e.g. use
:entry, :changes, :value) throughout, or alternatively change
whatsapp_cloud_event_type to use string keys to match processed_params—pick one
consistent convention and update references in whatsapp_cloud_event_type and
processed_params so both use the same key style (refer to methods
whatsapp_cloud_event_type and processed_params).
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
app/services/whatsapp/incoming_message_whatsapp_cloud_service.rbspec/services/whatsapp/incoming_message_whatsapp_cloud_service_spec.rb
spec/services/whatsapp/incoming_message_whatsapp_cloud_service_spec.rb
Outdated
Show resolved
Hide resolved
|
Codex Review: Didn't find any major issues. You're on a roll. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Pull Request Template
Description
Please include a summary of the change and issue(s) fixed. Also, mention relevant motivation, context, and any dependencies that this change requires.
Fixes # (issue)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.
Checklist:
This change is
Summary by CodeRabbit
New Features
Tests